package ru.algorithm.join;

/**
 * Yuri Zemlyanskiy <urikz@yandex-team.ru>
 * Date: 05.05.2011
 */
public class TresholdDistanceCondition<T> implements JoinCondition<T> {

    final private double treshold;
    final private Distance<T> distance;

    public TresholdDistanceCondition(final Distance<T> distance, final double treshold) {
        this.treshold = treshold;
        this.distance = distance;
    }

    public boolean isJoin(T t1, T t2) {
        return distance.dist(t1, t2) <= treshold;
    }
}
